<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%
    if (session.getAttribute("loggedIn") != null) 
    {
        if (((Boolean) session.getAttribute("loggedIn"))) 
        {
            if (session.getAttribute("role").equals("courier")) 
            {
                response.sendRedirect("courier_shipments.jsp");
            } 
            else if (!session.getAttribute("role").equals("admin")) 
            {
                response.sendRedirect("index.jsp");
            }
        } else {
            response.sendRedirect("index.jsp");
        }
    } else {
        response.sendRedirect("index.jsp");
    }
%>


<s:layout-render name="/managerlayout.jsp" headline="Delivery Service">
    <s:layout-component name="body">
        <s:useActionBean var="actionBean" beanclass="cz.muni.fi.pa165.web.ManagerTarrifActionBean" />
        <h2 style="text-align: center;"><f:message key="ManagerTariffNewheading"/></h2>
        <s:form style="padding-left: 28%; padding-top: 5%;" action="/TarrifManager.addtarrif">
            <div style="text-align: center;">
                <s:errors/> 
            </div>
                <table class="addForm">
                    <tr>
                        <th style="text-align: left;"><f:message key="/TarrifManager.addtarrif.name"/></th>
                        <td style="padding-left: 5%;"><s:text id="name" name="tarrif.name"/></td>
                    </tr>
                    <tr>
                        <th style="text-align: left;"><f:message key="/TarrifManager.addtarrif.pricekg"/></th>
                        <td style="padding-left: 5%;"><s:text id="pricekg" name="tarrif.pricePerKG"/></td>
                    </tr>
                    <tr>
                        <th style="text-align: left;"><f:message key="/TarrifManager.addtarrif.pricekm"/></th>
                        <td style="padding-left: 5%;"><s:text id="pricekm" name="tarrif.pricePerKM"/></td>
                    </tr>
                    <tr>
                        <th style="text-align: left;"><f:message key="/TarrifManager.addtarrif.fee"/></th>
                        <td style="padding-left: 5%;"><s:text id="fee" name="tarrif.deliveryFee"/></td>
                    </tr>
                    <tr>
                        <th> </th>
                        <td style="padding-left: 5%;"><s:submit class="btn btn-block" name="save"><f:message key="ManagerTariffNew"/></s:submit></td>
                    </tr>
                </table>
        </s:form>
    </s:layout-component>
</s:layout-render>
